<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>要求将数组中的0项去掉，将不为0的值存入一个新的数组，生成新的数组</title>
</head>

<body>
    <script>
        var arr1 = [0, 1, 0, 2, 46, 0, 9, 0, 22, 33];
        var arr2 = [];
        for (var i = 0, len = arr1.length; i < len; i++) {
            if (arr1[i] !== 0) {
                arr2.push(arr1[i]);
            }
        }
        console.log(arr2);
    </script>
</body>

</html>